package de.nordakademie.hausarbeit.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import de.nordakademie.hausarbeit.services.StylesheetGrammarAccess;
import de.nordakademie.hausarbeit.stylesheet.Color;
import de.nordakademie.hausarbeit.stylesheet.Font;
import de.nordakademie.hausarbeit.stylesheet.Form;
import de.nordakademie.hausarbeit.stylesheet.GreySubtitle;
import de.nordakademie.hausarbeit.stylesheet.HighDiv;
import de.nordakademie.hausarbeit.stylesheet.InputField;
import de.nordakademie.hausarbeit.stylesheet.NoBorderTable;
import de.nordakademie.hausarbeit.stylesheet.Stylesheet;
import de.nordakademie.hausarbeit.stylesheet.StylesheetPackage;
import de.nordakademie.hausarbeit.stylesheet.Text;
import de.nordakademie.hausarbeit.stylesheet.Title;
import de.nordakademie.hausarbeit.stylesheet.WideBorderTable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

@SuppressWarnings("all")
public class StylesheetSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private StylesheetGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == StylesheetPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case StylesheetPackage.COLOR:
				if(context == grammarAccess.getColorRule()) {
					sequence_Color(context, (Color) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.FONT:
				if(context == grammarAccess.getFontRule()) {
					sequence_Font(context, (Font) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.FORM:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getFormRule() ||
				   context == grammarAccess.getRuleRule()) {
					sequence_Form(context, (Form) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.GREY_SUBTITLE:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getGreySubtitleRule() ||
				   context == grammarAccess.getRuleRule()) {
					sequence_GreySubtitle(context, (GreySubtitle) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.HIGH_DIV:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getHighDivRule() ||
				   context == grammarAccess.getRuleRule()) {
					sequence_HighDiv(context, (HighDiv) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.INPUT_FIELD:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getInputFieldRule() ||
				   context == grammarAccess.getRuleRule()) {
					sequence_InputField(context, (InputField) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.NO_BORDER_TABLE:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getNoBorderTableRule() ||
				   context == grammarAccess.getRuleRule()) {
					sequence_NoBorderTable(context, (NoBorderTable) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.STYLESHEET:
				if(context == grammarAccess.getStylesheetRule()) {
					sequence_Stylesheet(context, (Stylesheet) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.TEXT:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getRuleRule() ||
				   context == grammarAccess.getTextRule()) {
					sequence_Text(context, (Text) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.TITLE:
				if(context == grammarAccess.getHeaderRule() ||
				   context == grammarAccess.getRuleRule() ||
				   context == grammarAccess.getTitleRule()) {
					sequence_Title(context, (Title) semanticObject); 
					return; 
				}
				else break;
			case StylesheetPackage.WIDE_BORDER_TABLE:
				if(context == grammarAccess.getBodyRule() ||
				   context == grammarAccess.getRuleRule() ||
				   context == grammarAccess.getWideBorderTableRule()) {
					sequence_WideBorderTable(context, (WideBorderTable) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_Color(EObject context, Color semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StylesheetPackage.Literals.COLOR__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StylesheetPackage.Literals.COLOR__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getColorAccess().getNameIDTerminalRuleCall_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name=STRING
	 */
	protected void sequence_Font(EObject context, Font semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StylesheetPackage.Literals.FONT__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StylesheetPackage.Literals.FONT__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getFontAccess().getNameSTRINGTerminalRuleCall_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID tabletext=[Text|ID]?)
	 */
	protected void sequence_Form(EObject context, Form semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID tabletext=[Text|ID]?)
	 */
	protected void sequence_GreySubtitle(EObject context, GreySubtitle semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_HighDiv(EObject context, HighDiv semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StylesheetPackage.Literals.BODY__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StylesheetPackage.Literals.BODY__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getHighDivAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_InputField(EObject context, InputField semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, StylesheetPackage.Literals.BODY__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StylesheetPackage.Literals.BODY__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getInputFieldAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID tabletext=[Text|ID]?)
	 */
	protected void sequence_NoBorderTable(EObject context, NoBorderTable semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     ((color+=Color color+=Color*)? (font+=Font font+=Font*)? rules+=Rule*)
	 */
	protected void sequence_Stylesheet(EObject context, Stylesheet semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID? color=[Color|ID] font=[Font|ID])
	 */
	protected void sequence_Text(EObject context, Text semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID tabletext=[Text|ID]?)
	 */
	protected void sequence_Title(EObject context, Title semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID tabletext=[Text|ID]?)
	 */
	protected void sequence_WideBorderTable(EObject context, WideBorderTable semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
